﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TeleRad.Services;
using System.IO;
using VikingErik.Mvc.ResumingActionResults;

namespace TeleRad.Controllers
{
    [Authorize]
    public class FilesController : Controller
    {
        private readonly IContentService _ContentService;
        
        public FilesController(IContentService ContentService)
        {
            this._ContentService = ContentService;
        }

        public FileStreamResult Content(int cid, int pid, string filename, string type)
        {

            // Changes
            FileStream resource_stream = _ContentService.GetRequestedFile(cid,pid,filename);
            //if (resource_stream == null)
              //  return View("Index");
            //else
            return File(resource_stream, type);
           // return new ResumingFileStreamResult(resource_stream,type);
        }

        public string Index()
        {
            return "Not a valid Request!";
        }

    }
}
